package com.github.binarywang.demo.wx.miniapp.interceptor;

import com.github.binarywang.demo.wx.miniapp.annotation.support.LoginUserHandlerMethodArgumentResolver;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.method.support.HandlerMethodArgumentResolver;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

import javax.annotation.Resource;
import java.util.List;

/**
 * 拦截器配置
 *
 * @Author guoyb
 * @Date 2020/11/27  11:31
 */
@Configuration
public class CustomWebMvcConfigure implements WebMvcConfigurer {

    @Resource
    AppIntercepter appIntercepter;

    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        //添加要拦截的url     //拦截的路径
        registry.addInterceptor(appIntercepter).addPathPatterns("/wx/app/**");
        WebMvcConfigurer.super.addInterceptors(registry);
    }

    @Override
    public void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
        argumentResolvers.add(new LoginUserHandlerMethodArgumentResolver());
    }
}
